<?php


namespace app\admin\controller;


use easyadmin\app\columns\form\FormText;
use easyadmin\app\columns\lists\ListText;
use easyadmin\app\libs\ListField;
use easyadmin\app\libs\PageForm;
use easyadmin\app\libs\Pagination;

class Notice extends Admin
{
    protected $pageName = 'App公告';
    protected $tableName = 'app_notice';

    protected function configListField(ListField $list)
    {
        $list
            ->addField('id', '公告ID', ListText::class)
            ->addField('title', '公告标题', ListText::class)
            ->addField('text', '公告标题', ListText::class)
            ;
    }

    protected function configShowField(ListField $field)
    {
        $field
            ->addField('id', '公告ID', ListText::class)
            ->addField('title', '公告标题', ListText::class)
            ->addField('text', '公告标题', ListText::class)
            ;
    }
    protected function configFormField(PageForm $page)
    {
        $page
            ->addField('title', '公告标题', FormText::class,[
                'required'=>true
            ])
            ->addField('text', '公告内容', FormText::class,[
                'required'=>true
            ])
            ;
    }
    protected function configListPagination(Pagination $pagination)
    {
        $pagination->setPageSize(20);
    }
    protected function insertBefore($data): array
    {
        $data['time'] = time();
        $data['create_time'] = time();
        return $data;
    }
}